package com.dna.utils;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 查询参数
 * 
 * @param <T>
 *
 */
public class Query<T> extends LinkedHashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	// 当前页码
	private int page;
	// 每页条数
	private int limit;
	
	private int startRow;

	private T t;

	public Query(Map<String, Object> params, Class<T> clazz) {

        try {
            if (!params.isEmpty()) {
                this.setT(MapUtils.mapTbean(params,clazz));
            }
           
         // 分页参数
            this.page = Integer.parseInt(params.get("page").toString());
            this.limit = Integer.parseInt(params.get("limit").toString());
            this.startRow = page > 0 ? (page - 1) * limit : 0;
            
        } catch (Exception e) {
            e.printStackTrace();
        }
		
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public T getT() {
		return t;
	}

	public void setT(T t) {
		this.t = t;
	}

    public int getStartRow() {
        return startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }
}
